﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WOMPS
{
    public partial class MonitorDirectory : Form
    {
        public MonitorDirectory()
        {
            InitializeComponent();
            cbShowType.DataSource = Enum.GetValues(typeof(APIType));
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            txtDirectory.Text = folderBrowserDialog1.SelectedPath;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (CheckForm())
            {
                MonitoredDirectory md = new MonitoredDirectory();
                md.DateDivider = Convert.ToChar(txtDateDivider.Text);
                md.Directory = txtDirectory.Text;
                md.Divider = Convert.ToChar(txtDivider.Text);
                APIType st;
                Enum.TryParse<APIType>(cbShowType.SelectedValue.ToString(), out st);
                md.APISource = st;
                md.HoursToGoBack = Convert.ToInt16(txtHours.Text);
                Globals.MonitoredDirectories.Add(md);
                this.Close();
                
            }
            else
            {
                MessageBox.Show("Form is not completed!", "Error", MessageBoxButtons.OK);
            }
        }
        private bool CheckForm()
        {
            if (txtDirectory.Text != "" && txtDateDivider.Text != "" && txtDivider.Text != "")
                return true;
            else
                return false;
        }

        private void MonitorDirectory_Load(object sender, EventArgs e)
        {

        }
    }
}
